#include <iostream>
using namespace std;


int main()
{
   int a,b,f;
   char c;
   scanf("%d%d %c%d",&a,&b,&c,&f);
   if(f)
   {
   	for(int i = 1;i<=a;i++)
   	{
   		for(int j = 1;j<=b;j++)
   		{
   		  cout << c;	
		}
		cout << endl;
	}
   }
   else
   {
   	int i,j;
   	for(i = 1;i<=a;i++)
   	{
   		for(j = 1;j<=b;j++)
   		{
   			if(i==1||j==1||i==a||j==b)
   			{
   				cout << c;
			}
			else
			cout <<" ";
		}
		cout << endl;
	}
   }
   	
}
